<template>
  <section class="tt-recommend">
    <div class="tt-recommend-box">
      <!-- 标题 -->
      <my-title><span>精品推荐</span></my-title>
      <!-- 内容 -->
      <div class="box-banner">
        <!-- 图片 -->
        <div class="banner-container">
          <ul>
            <!-- 最后一张图 -->
            <li>
              <a href="#">
                <img :src="bastList[bastList.length - 1].path" alt="" />
              </a>
            </li>
            <!-- 循环精品推荐的数组 -->
            <li v-for="item in bastList" v-bind:key="item.id">
              <a href="#">
                <img :src="item.path" alt="" />
              </a>
            </li>
            <!-- 第一张  -->
            <li>
              <a href="#">
                <img :src="bastList[0].path" alt="" />
              </a>
            </li>
          </ul>
        </div>
        <!-- 导航点 -->
        <div class="banner-point">
          <ol>
            <li class="active"></li>
            <li></li>
          </ol>
        </div>
      </div>
    </div>
  </section>
</template>

<style lang="less" scoped>
@import "../../assets/less/variable.less";
.tt-recommend {
  margin-top: 10px;
  min-height: 120px;
  background-color: #fff;
  padding: @padding2;
  padding-top: 0;
  .tt-recommend-box {
    width: 100%;
    min-height: 120px;
    overflow: hidden;
  }
}

.box-banner {
  width: 100%;
  position: relative;
  padding-bottom: 14px;
  .banner-container {
    width: 100%;
    overflow: hidden;
    ul {
      width: 1000%;
      transform: translateX(-10%);
      &::after {
        content: "";
        display: block;
        clear: both;
      }
      li {
        width: 10%;
        float: left;
        a {
          display: block;
          width: 100%;
          img {
            width: 100%;
            display: block;
          }
        }
      }
    }
  }
  .banner-point {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 14px;
    // background-color: red;
    ol {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 100%;
      height: 14px;
      li {
        width: 10px;
        height: 4px;
        background-color: @bgColor3;
        margin: 0 5px;
        border-radius: 2px;
        transition: width 0.5s linear;
      }
      .active {
        width: 20px;
      }
    }
  }
}
</style>

<script>
import myTitle from "@/components/mytitle";
import { mapState } from "vuex";
export default {
  components: {
    myTitle,
  },
  data() {
    return {
      bastList: [],
    };
  },
  computed: {
    ...mapState(["home"]),
  },
  created() {
    let arr = this.$store.state.home.bastBanner;
    // console.log(arr,'精品推荐组件 渲染数据 2.0');
    arr.forEach((element) => {
      this.bastList.push(element);
    });
  },
};
</script>